<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
  const p =  new Promise((resolve,reject)=>{
    try{
        console.log('开始获取');
        setTimeout(() => {
            // throw new Error('错误')
            console.log('获取成功');
            resolve('成功')
            // reject('错误')
        }, 1000);
        
    }catch(e){
        //处理错误信息
        reject(e.message)
        console.log(e.message);
    }
})
.then(()=>{
    //如果成功的实例进入到then里，再进行抛错，先同步打印，然后抛错进入到catch
        console.log(1);
        throw new Error('错误')
    })
.catch(()=>{
    // 这里返回一个 失败的promise实例，返回值 2 
        console.log(2);
        return 2
    })
 
    console.log(p);
    </script>
</body>
</html>